<template>
    <div>
        <rui-page :defines="defines">
            <rui-query :label-width="240"
                       ref="searchForm"
                       :query="queryData"
                       :query-rows="searchFormOptions"
            >
            </rui-query>
            <rui-table
                :defineId="'productApproveTaskDefine'"
                :fixedLeft="['action']"
                :showIndex="false"
                :select="false"
                :columns="columns"
                :slots="[{key:'action',slot:'action'}]"
                @loadDatas="queryData"
                ref-query="searchForm"
                ref="taskTable"
            >
                <template slot="action" slot-scope="{ row }">
                    <div>
                        <Button type="primary" size="small" @click="view(row)">详情</Button>
                    </div>
                </template>
            </rui-table>
        </rui-page>
    </div>
</template>
<script>
    import productApproveTaskDefine from "./defines/product-approve-task-define";

    import {
        getWorkTaskSum
    } from "@/projects/afs-core-business/api/afs-product/approve/approveTask";

    export default {
        name: "approve-task",
        components: {},
        data() {
            return {
                stageId:null,
                taskNodeId:null,
                isShow: true,
                launchShow:false,
                searchFormOptions: [
                    {
                        defineId: "productApproveTaskDefine", span: 12, fields: ["taskName"]
                    },
                ],
                columns: [
                    'action', 'taskName', 'taskNum'
                ],
                parms: {}
            };
        },
        computed: {
            defines() {
                return [
                    {
                        id: "productApproveTaskDefine",
                        fields: productApproveTaskDefine
                    }
                ];
            }
        },
        mounted() {
            this.refresh();
        },
        methods: {
            queryData(queryData) {
                getWorkTaskSum(queryData).then(res => {
                    if (res.code === "0000") {
                        let {records, total} = res.data;
                        this.$refs.taskTable.updateTableData(records, total);
                    }
                });
            },
            refresh() {
                this.$refs['taskTable'].reloadData();
            },
            view(v) {
                console.info(JSON.stringify(v));
                if(v.afsFlowKey == "productlaunch"){
                    console.info("taskNodeId"+v.taskNodeId);
                    console.info("afsFlowKey"+v.afsFlowKey);
                    this.afs.newTab(this,'projects/afs-core-business/pages/product/approve-task/approveTaskProductlaunch','产品上线流程审批','ios-add',{afsFlowKey:v.afsFlowKey,taskNodeId:v.taskNodeId},v.taskNodeId,[],true);
                }
                if(v.afsFlowKey == "productmodify"){
                    console.info("taskNodeId"+v.taskNodeId);
                    console.info("afsFlowKey"+v.afsFlowKey);
                    this.afs.newTab(this,'projects/afs-core-business/pages/product/approve-task/approveTaskProductmodify','产品修改流程审批','ios-add',{afsFlowKey:v.afsFlowKey,taskNodeId:v.taskNodeId},v.taskNodeId,[],true)
                }

            },
        }
    };
</script>
